//
//  Repos1TableViewCell.m
//  GitBucket
//
//  Created by gdm on 15/11/6.
//  Copyright © 2015年 ios25. All rights reserved.
//

#import "Repos1TableViewCell.h"

@implementation Repos1TableViewCell

- (void)awakeFromNib {
    // Initialization code
    _starImage.image = [UIImage imageNamed:@"fullStar.png"];
    _xImage.image = [UIImage imageNamed:@"smallFork.png"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//重写modelset方法
-(void)setModel:(OwnedModel1 *)model
{
    self.typeImageView.image = model.typeImage;
    //设置title颜色，如果有/则后面的子有颜色，如果没/全部有颜色
    if ([model.title rangeOfString:@"/"].location != NSNotFound) {
        self.titleLabel.textColor = [UIColor blackColor];
        NSRange range = [model.title rangeOfString:@"/"];
        //取得/后面的字符串range
        NSRange hasColorRange = {range.location+1,model.title.length-range.location-1};
        //构建有格式的字符串
        NSMutableAttributedString *at = [[NSMutableAttributedString alloc]initWithString:model.title];
        [at addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:hasColorRange];
        NSLog(@"at:%@",at);
        self.titleLabel.attributedText = at;
    }else{self.titleLabel.text = model.title;
        self.titleLabel.textColor = [UIColor blueColor];
    }
    self.detailLabel.text = model.detail;
    self.starNumberLabel.text = model.starNumber;
    self.xNumberLabel.text = model.xNumber;
    self.dataDic = model.dataDic;
}

@end
